﻿using System.Web.Mvc;
using AllIsWell.Services.Infrastructure;

namespace AllIsWell.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly IPageService _pageService;
        private int _startItWellDestinyId;

        public HomeController(IPageService pageService)
        {
            _pageService = pageService;
            _startItWellDestinyId = 1;
        }

        public ViewResult Index()
        {
            ViewResult indexView;

            if (_pageService.IsTodaysPageExists(_startItWellDestinyId))
            {
                var todaysPage = _pageService.GetTodaysPage(_startItWellDestinyId);
                indexView = View(todaysPage);
            }
            else
            {
                indexView = View();
            }
            return indexView;
        }
    }
}
